﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Cotizav.CONEXION;
using Cotizav.PRESENTACION.Controls;


namespace Cotizav.PRESENTACION.Personas.Vendedor
{
    public partial class RegistroVendedor : Form
    {
        IURegistroVendedor iuRegistro;

        CtrlVendedor controlador;

        public RegistroVendedor()
        {
            InitializeComponent();

            iuRegistro = new IURegistroVendedor();
            controlador = new CtrlVendedor();
        }
        
        private void RegistroCliente_Load(object sender, EventArgs e)
        {
            loadGridVendedores();
        }

        public void loadGridVendedores()
        {
            SplitContainer panelMaestro = panelRegistro.Controls["splitContainer1"] as SplitContainer;
            panelMaestro.Panel2.Controls.Add(iuRegistro);

            DataGridView dg = panelMaestro.Panel1.Controls["gridListObjetos"] as DataGridView;
            AutoCompleteTextbox completeTextBox = panelMaestro.Panel1.Controls["txtBuscarContains"] as AutoCompleteTextbox;
            List<VENDEDOR> vendedores = controlador.getListVendedor();
            
            dg.DataSource = null;
            dg.DataSource = vendedores;
            dg.ClearSelection();

            completeTextBox.AutoCompleteList = vendedores.Select(x => x.nombre).ToList<string>();
        }         
    }
}
